/*!
\file ThirdPersonCamera.h
\author Po
\brief A third person camera can focus on the Target and send Y axis rotation command to the Target.
*/
#pragma once

#include <d3d9.h>
#include <d3dx9.h>
#include "Interface.h"

/*!
\class ThirdPersonCamera
\brief A third person camera can focus on the Target and send Y axis rotation command to the Target.
*/
class ThirdPersonCamera
{
public:
	/*! Construct a platform with IDirect3DDevice9 (<b>NOT</b> own this device). */
	ThirdPersonCamera(IDirect3DDevice9 *pd3dDevice);
	/*! Destruct this camera. */
	~ThirdPersonCamera(void);

public:
	/*! Should set trace target before ThirdPersonCamera::Update(), camera <b>NOT</b> owns target. */
	void SetTarget(Target *pTarget);
	/*! Set camera distance to the target. */
	void SetDistance(float fDist);

public:
	/*! Should call this function one frame a time. */
	void Update();

private:
	void UpdateView();
	void UpdateTargetDirection();
	void SetProjection();

private:
	LPDIRECT3DDEVICE9 m_pd3dDevice;

	D3DXMATRIX m_matView;          
	D3DXMATRIX m_matProj;   

	D3DXVECTOR3 m_vecRight;
	D3DXVECTOR3 m_vecUp;
	D3DXVECTOR3 m_vecLook;

	D3DXVECTOR3	m_vecCameraPosition; 
	D3DXVECTOR3	m_vecTargetPosition; 

	float m_fDist;
	float m_fDistMin;
	float m_fDistMax;
	float m_fRotationAngleY;
	Target *m_pTarget;
};

